			var sys_pwd_index;
			
			var consume_pwd_index;
			
			var consume_nopwd_index;
			var showConsumePwdDiv = "0";
			
			var pos_xfxx = 0;//次消费限额
			
			var quatoMode = "0";//定额模式
			var quatoMoney = "0";//定额金额
			
			$(function(){
				var rs = appControl.srchSysInfo('4');
				//alert(rs);
				var jsonData = JSON.parse(rs);
				if(jsonData.is_success!="1"){
					$("#syslog").html("鑫三强消费终端");
				}else{
					if(jsonData.sysTitle==""){
						$("#syslog").html("鑫三强消费终端");
					}else{
						$("#syslog").html(jsonData.sysTitle);
					}
					
				}
				pos_xfxx = parseInt(jsonData.xfxe);
				
				var quatoInfo = appControl.srcQuatoInfo();
				var quatoJSON = JSON.parse(quatoInfo);
				if(quatoJSON.is_success=="1"){
					quatoMode = quatoJSON.quatoMode;
					quatoMoney = quatoJSON.quatoMoney;
				}
				
				
				if(quatoMode=="1"){
					$("#quatoTip").html("定额消费");
					$("#input_money").val(quatoMoney);
					$("#input_money").attr("readonly","readonly");
				}
			});
			
			
			
			
			
			//跳转到系统设置页面
			function toSysSet(){
				
				
				$("#operPwd").val("");
				
				sys_pwd_index = layer.open({
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['800px', '400px'], //宽高
				  content:$("#pwdDiv"),
				  title:"系统密码验证",
				  offset: '10px'
				});
				
				$("#operPwd").focus();
				
			}
		
			function cancelSubmitPwd(doType){
				layer.close(sys_pwd_index);	
			}
			
			function submitPwd(doType){
				var pwd = $.trim($("#operPwd").val());
				if(pwd==""){
					layer.msg("请输入系统管理员密码");
					return;
				}
				if(doType=="1"){
					var rs = appControl.validateSysSetPwd(pwd);
					if(rs=="1"){
						appControl.goToSysSet(pwd);
					}else if(rs=="0"){
						$("#operPwd").val("")
						layer.msg("密码错误");
					}else{
						$("#operPwd").val("")
						layer.msg("系统错误");
					}
					
				}else if(doType=="2"){
					//消费管理页面
					
				}else{
					alert('未知操作');	
				}
			}
			
			//跳转到消费管理页面
			function toConsume(){
				
				appControl.goToConsumeSet();
				
			}
      	
			var consumeBackPwdIndex;
			
			function toConsumeBackFromIndex(){
					
					
				$("#backOperPwd").val("");
				
				consumeBackPwdIndex = layer.open({
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['800px', '400px'], //宽高
				  content:$("#backPwdDiv"),
				  title:"消费密码验证",
				  offset: '10px'
				});
				
				$("#backOperPwd").focus();
					
			}
			
			
			function submitBackPwd(){
				var pwd = $.trim($("#backOperPwd").val());
				if(pwd==""){
					layer.msg("请输入操作密码");
					return;
				}
				var rs = appControl.validateOperPwd(pwd);
				if(rs=="1"){
					
					appControl.toConsumeBackFromIndex();
					
					goType = "";
				}else if(rs=="0"){
					$("#operPwd").val("")
					layer.msg("密码错误");
				}else{
					$("#operPwd").val("")
					layer.msg("系统错误");
				}
			}
			
			function cancelBackSubmitPwd(){
				layer.close(consumeBackPwdIndex);
			}
			
			function goConsumeBackFromIndex(){
				
				
				
				appControl.toConsumeBackFromIndex();
			}
			
			function toConsumeJcFromIndex(){
				
			}


		function srchTodayFlow(){
			appControl.toSrchTodayFlow();
		}


		//页面操作监听器
		var operListener;

		var curCardsno ;
		var curCardno;
		
		
		var canConsume = "0";
		
		function showCardUserInfo(rs){
			
			
			showConsumePwdDiv = "0";
		
			$("#curUsername").text("");
			$("#curMoney").text("");
			
			var jsonData = JSON.parse(rs);
			if(jsonData.is_success=="-1"){
				layer.msg("服务器没响应,请重新再试");
			}else if(jsonData.is_success=="-2"){
				layer.msg(jsonData.error_msg);
			}else if(jsonData.is_success=="0"){
				layer.msg(jsonData.error_msg);
			}else{
				//查询用户存在
				//alert(jsonData.username);
				$("#curUsername").text(jsonData.username);
				$("#curMoney").text(jsonData.curMoney);
				
				
				$("#costMoney").text("");
       			$("#remainMoney").text("");
				
				curCardsno = jsonData.cardsno;
				curCardno = jsonData.cardno;
				
				
				if(quatoMode=="1"){
					//定额模式，刷卡直接扣费
					goConsumeWithNoPwd();
					return;
				}
				
				//$("#input_money").click();
				$("#input_money").focus();
				
				//15秒后如果不操作,清除刷卡的用户信息
				
				if(operListener!=undefined){
					window.clearInterval(operListener);
				}
				var n = 30;
				operListener = setInterval(function(){
					
					if(n>=0){
						$("#cardTip").css("display","block");
						$("#syTime").html(n);
					}else{
						
						curCardsno = "";
						curCardno = "";
						
						$("#cardTip").css("display","none");
						
						$("#curUsername").text("");
						$("#curMoney").text("");
						$("#costMoney").text("");
       					$("#remainMoney").text("");
       					
       					showConsumePwdDiv = "0";
       					
       					clearMoney();
       					
       					layer.close(consume_pwd_index);
       					
       					if(quatoMode=="1"){
							$("#input_money").val(quatoMoney);
							$("#input_money").attr("readonly","readonly");
						}
       					
       					if(operListener!=undefined){
       						window.clearInterval(operListener);
       					}
       					
					}
					n--;
					
				},1000)
			}
		}


		

		function doConsume(){
			
			var jy_money = $.trim($("#input_money").val());

			if(jy_money==""){
				layer.msg("请输入消费金额");
				return;
			}
			
			if(isNaN(jy_money)){
				layer.msg("消费金额格式错误");
				return;
			}
			if(jy_money-0<0){
				layer.msg("交易金额必须大于0");
				return;
			}
			
			if(parseInt(jy_money)<0){
				layer.msg("交易金额必须大于0,不能为负数");
				return;
			}
			
			
			if(parseInt(jy_money)>10000){
				layer.msg("交易金额不能大于10000");
				return;
			}
			
			//layer.msg(jy_money);
			canConsume = "1";
			if(curCardsno == "" || curCardsno==undefined){
				layer.msg("请刷消费卡...");
				return;
			}
			
			
			
			var rs = appControl.srchSysInfo('4');
			var jsonData = JSON.parse(rs);
			if(jsonData.is_success=="1"){
				pos_xfxx = parseInt(jsonData.xfxe);
			}
			
			
			//$('#colseBox').click();
			
			if(parseInt(pos_xfxx)> 0 &&  pos_xfxx-$.trim($("#input_money").val())*100<0){
				showConsumePwdDiv = "1";
			}else{
				showConsumePwdDiv = "0";
			}
			
			var flag = showConsumePwdDiv;
			//如果超过次消费限额,则需要显示输入用户密码页面
			
			if(flag=="0"){
				$("#confirm_money_nopwd").val(jy_money+"  元");
				//不需要输入消费密码
				
			  	consume_nopwd_index = layer.open({
				  type: 1,
				  title: "交易金额确认",
				  closeBtn: 0,
				  shadeClose: false,
				  area: ['800px', '400px'], //宽高
				  content: $("#consumeConfirm")
				});
				
				
			}else{
				$("#confirm_money").val(jy_money+"  元");
				consume_pwd_index = layer.open({
					  type: 1,
					  skin: 'layui-layer-rim', //加上边框
					  area: ['800px', '400px'], //宽高
					  content:$("#consumePwdDiv"),
					  title:"输入用户消费密码",
					  offset: '10px'
					});
				
				$("#consumePwd")[0].focus();
			}
				
		}
		
		function clearMoney(){
			
			if(quatoMode=="1"){
				
				$("#consumePwd").val("");
				
				showConsumePwdDiv = "0";
			}else{
				$("#input_money").val("");
				$("#consumePwd").val("");
				
				showConsumePwdDiv = "0";
			}
		}

		function goConsumeWithNoPwd(){
			appControl.doConsumeRequest(curCardsno,curCardno,"",$.trim($("#input_money").val()));
		}
		
		function closeConsumeWithNoPwd(){
			layer.close(consume_nopwd_index);
			showConsumePwdDiv = "0";
		}
		

		document.onkeypress=function(event){   
            var e = event || window.event || arguments.callee.caller.arguments[0];   
            
            
            //alert(e.keyCode);
            if(e && e.keyCode==13 && showConsumePwdDiv=="1"){ // enter 键   
                //layer.msg("提交扣款交易...");     
                
				if(curCardsno == "" || curCardsno==undefined){
					layer.msg("请刷消费卡...");
					return;
				}
                
                 if($.trim($("#input_money").val())==""){
					layer.msg("请输入消费金额");
					return;
				}
                
                if($.trim($("#consumePwd").val())==""){
                	layer.msg("请输入消费密码...");
                	return;
                }
                appControl.doConsumeRequest(curCardsno,curCardno,$.trim($("#consumePwd").val()),$.trim($("#input_money").val()));
                showConsumePwdDiv=="0";
                
            }  
       };   
       
       
       function showConsumeResult(rs){
       		//alert(rs);
       		var jsonData = JSON.parse(rs);
       		if(jsonData.is_success=="0"){
       			layer.close(consume_pwd_index);
       			$("#consumePwd").val("");
       			layer.msg(jsonData.msg);
       		}else if(jsonData.is_success=="1"){
       			
       			layer.msg(jsonData.msg);
       			
	
				$("#cardTip").css("display","none");
						

       			$("#costMoney").text(jsonData.jyMoney);
       			$("#remainMoney").text(jsonData.kyMoney);
       			
       			if(quatoMode=="1"){
       				//金额不变
       			}else{
       				$("#input_money").val("");
       			}
       			
       			
       			$("#consumePwd").val("");
       			
       			curCardsno = "";
				curCardno = "";
       			
       			layer.close(consume_pwd_index);
       			layer.close(consume_nopwd_index);
       			
       			
       			
       			
       			if(operListener!=undefined){
					window.clearInterval(operListener);
				}
				var n = 3;
				operListener = setInterval(function(){
					
					if(n>=0){
						//$("#cardTip").css("display","block");
						//$("#syTime").html(n);
					}else{
						
						curCardsno = "";
						curCardno = "";
						
						$("#cardTip").css("display","none");
						
						$("#curUsername").text("");
						$("#curMoney").text("");
						$("#costMoney").text("");
       					$("#remainMoney").text("");
       					
       					showConsumePwdDiv = "0";
       					
       					//clearMoney();
       					
       					layer.close(consume_pwd_index);
       					
       					if(quatoMode=="1"){
							$("#input_money").val(quatoMoney);
							$("#input_money").attr("readonly","readonly");
						}
       					
       					if(operListener!=undefined){
       						window.clearInterval(operListener);
       					}
       					
					}
					n--;
					
				},1000)
       			
       			
       			
       		}else{
       			layer.msg("发生未知错误...");
       		}
       }



	